﻿/******************************************************************************
 * Name         : LoginPlayerManager.hpp
 * Author       : 671643387
 * Date         : 2015年9月14日
 * Description  :
 *****************************************************************************/

#ifndef LOGIN_SERVER_PLAYER_LOGINPLAYERMANAGER_HPP_
#define LOGIN_SERVER_PLAYER_LOGINPLAYERMANAGER_HPP_

#include <dev/base/Mutex.hpp>
#include <dev/base/LockedMap.hpp>
#include <common/player/PlayerManager.hpp>
#include "LoginPlayerFactory.hpp"

namespace sxr
{
	namespace login_server
	{
		class LoginPlayerManager : public common::PlayerManager
		{
		public:
			LoginPlayerManager(void);
			virtual ~LoginPlayerManager(void);

			static LoginPlayerManager* getMe(void);

		public:
			virtual bool initialize(void);
            virtual void cleanup(void);
            virtual bool newPlayer(dev::net::TcpConnectionPtr& conn);

        public:
            void removePlayer(LoginPlayer& player);

        private:
            LoginPlayerFactoryPtr playerFactory_;

            typedef dev::base::LockedMap<int, LoginPlayerPtr, dev::base::Mutex> LoginPlayerMap;
            LoginPlayerMap players_;
		};
	}
}


#endif /* LOGIN_SERVER_PLAYER_LOGINPLAYERMANAGER_HPP_ */
